{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-09-04T01:54:12.928737Z",
     "start_time": "2025-09-04T01:54:11.389610Z"
    }
   },
   "source": [
    "import torchvision\n",
    "from torchvision import transforms"
   ],
   "outputs": [],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-04T01:54:12.936013Z",
     "start_time": "2025-09-04T01:54:12.933857Z"
    }
   },
   "cell_type": "code",
   "source": "transform = transforms.ToTensor()",
   "id": "51af57b7b0dd6f8",
   "outputs": [],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-04T01:54:14.216017Z",
     "start_time": "2025-09-04T01:54:12.944187Z"
    }
   },
   "cell_type": "code",
   "source": [
    "train_data = torchvision.datasets.CIFAR10(root='./dataset', train=True, download=True, transform=transform)\n",
    "test_data = torchvision.datasets.CIFAR10(root='./dataset', train=False, download=True, transform=transform)"
   ],
   "id": "faccb72b42eb5e9c",
   "outputs": [],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-04T01:56:12.908379Z",
     "start_time": "2025-09-04T01:56:12.902791Z"
    }
   },
   "cell_type": "code",
   "source": "train_data",
   "id": "c6d50d66276562c5",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Dataset CIFAR10\n",
       "    Number of datapoints: 50000\n",
       "    Root location: ./dataset\n",
       "    Split: Train\n",
       "    StandardTransform\n",
       "Transform: ToTensor()"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 8
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-04T01:54:14.307289Z",
     "start_time": "2025-09-04T01:54:14.303379Z"
    }
   },
   "cell_type": "code",
   "source": [
    "img, label = train_data[0]\n",
    "print(img.shape)\n",
    "print(label)"
   ],
   "id": "d1e71f471e2afb6e",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([3, 32, 32])\n",
      "6\n"
     ]
    }
   ],
   "execution_count": 5
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-04T01:54:14.427092Z",
     "start_time": "2025-09-04T01:54:14.327552Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from torch.utils.tensorboard import SummaryWriter\n",
    "writer = SummaryWriter(\"./logs\")\n",
    "for i in range(10):\n",
    "    img, label = train_data[i]\n",
    "    writer.add_image(\"CIFAR10\", img, i)\n",
    "\n",
    "writer.close()"
   ],
   "id": "bdc4fcd0bf6c15e9",
   "outputs": [],
   "execution_count": 6
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-04T01:55:23.977073Z",
     "start_time": "2025-09-04T01:55:23.971193Z"
    }
   },
   "cell_type": "code",
   "source": "train_data.classes",
   "id": "efdc4793adffeeb4",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['airplane',\n",
       " 'automobile',\n",
       " 'bird',\n",
       " 'cat',\n",
       " 'deer',\n",
       " 'dog',\n",
       " 'frog',\n",
       " 'horse',\n",
       " 'ship',\n",
       " 'truck']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 7
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
